<?php

declare(strict_types=1);

namespace app\admin\controller\trandingbank;

use think\facade\Request;
use app\common\service\TrandingbankAllowplayer as S;
use app\common\model\TrandingbankAllowplayer as M;
use app\common\model\GmTgczlogsTqk as TQKM;

class Allowplayer extends  \app\admin\controller\Base
{
    protected $middleware = ['AdminCheck', 'AdminPermission'];

    // 列表
    public function index()
    {
        if (Request::isAjax()) {
            return $this->getJson(M::getList());
        }
        return $this->fetch('index', ['ServerLs' => TQKM::getServerLsSelect()]);
    }

    // 添加
    public function add()
    {
        if (Request::isAjax()) {
            return $this->getJson(S::goAdd(Request::post()));
        }
        return $this->fetch('add', ['ServerLs' => TQKM::getServerLsSelect()]);
    }

    // 查询用户名
    public function queryuname()
    {
        $data = TQKM::getqueryuname(Request::post('actorname'), Request::post('serverid'));
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => $data,
        ];
        return json($response);
    }

    // 批量修改状态
    public function batchStatus()
    {
        return $this->getJson(S::goBatchStatus(Request::post('allowstatus'), Request::post('ids')));
    }

}
